{% extends 'customer_dashboard.html' %}

{% block content %}
<div class="card">
  <h2 style="font-size: 24px;"><i class="bi bi-cash"></i> 取款操作</h2>
  <p style="margin-top: 10px;">请选择要取款的银行卡并填写金额：</p>

  {% if message %}
    <p style="color: {{ 'green' if success else 'red' }}; margin: 15px 0;">{{ message }}</p>
  {% endif %}

  <form method="POST">
    <div class="form-group" style="margin-top: 20px;">
      <label for="cardID" style="font-size: 18px;"><i class="bi bi-credit-card"></i> 选择银行卡：</label>
      <select name="cardID" id="cardID" required style="font-size: 16px; padding: 6px;">
        <option value="">-- 请选择卡号 --</option>
        {% for card in cards %}
          <option value="{{ card.cardID }}"
                  {% if request.form.get('cardID') == card.cardID %}selected{% endif %}
                  {% if card.lost %}disabled{% endif %}>
            {{ card.cardID }} - {{ card.cardType or '未指定' }} - 余额: {{ "%.2f"|format(card.balance) }}{% if card.lost %}（已挂失）{% endif %}
          </option>
        {% endfor %}
      </select>
    </div>

    <div class="form-group" style="margin-top: 20px;">
      <label for="amount" style="font-size: 18px;"><i class="bi bi-dash-circle"></i> 取出金额：</label>
      <input type="number" step="0.01" min="0.01" name="amount" id="amount" required style="font-size: 16px; padding: 6px;">
    </div>

    <div style="margin-top: 30px;">
      <button type="submit" class="btn">确认取款</button>
      <a href="{{ url_for('customer.balance') }}" class="btn btn-secondary" style="margin-left: 10px;">返回</a>
    </div>
  </form>
</div>
{% endblock %}
